package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsFault;
import com.econ.powercloud.ems.dal.mapper.EmsFaultMapper;
import org.springframework.stereotype.Repository;

/**
 * @author zjr
 * @create 2021/7/30 上午9:11
 * @description
 */
@Repository
public class EmsFaultDAO extends ServiceImpl<EmsFaultMapper, EmsFault> {

    public EmsFault selectOneByFaultPid(String faultPid, Integer faultResource){
        LambdaQueryWrapper<EmsFault> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(EmsFault::getFaultPid,faultPid);
        wrapper.eq(faultResource!=null, EmsFault::getFaultResource,faultResource);
        wrapper.orderByDesc(EmsFault::getGmtCreate);
        wrapper.last("limit 1");
        return this.baseMapper.selectOne(wrapper);
    }
}
